package com.eightbears.beboy.base.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.eightbears.beboy.R;

/**
 * @创建者 Administrator
 * @创建时间 Created by Administrator on 2017/3/20.
 * @描述 用于个人页面---商家入驻
 * @更新 $Author$
 * @更新时间 2017/3/20
 * @更新描述 ${TODO}.
 */

public class SexDialog extends Dialog implements View.OnClickListener {
    private onDialogItemClickListener itemClickListener = null;
    private Context  mContext;
    private TextView tv_male;
    private TextView tv_female;


    public SexDialog(Context context, boolean cancelable, OnCancelListener cancelListener, Context mContext) {
        super(context, cancelable, cancelListener);
        this.mContext = mContext;
    }

    public SexDialog(Context context) {
        super(context, R.style.MyDialog);
        this.mContext = context;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_sex);
        initView();
        initEvent();
    }

    private void initView() {
        tv_male = (TextView) findViewById(R.id.tv_male);
        tv_female = (TextView) findViewById(R.id.tv_female);
        getWindow().setGravity(Gravity.CENTER);
        WindowManager.LayoutParams LayoutParams = getWindow().getAttributes();
        getWindow().setAttributes(LayoutParams);
    }

    private void initEvent() {
        tv_male.setOnClickListener(this);
        tv_female.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_male://男
                String s = tv_male.getText().toString();
                if (itemClickListener != null) {
                    itemClickListener.onItemClick(s);
                    dismiss();
                }
                break;
            case R.id.tv_female://女
                String k = tv_female.getText().toString();
                if (itemClickListener != null) {
                    itemClickListener.onItemClick(k);
                    dismiss();
                }
                break;
        }
    }


    public void setOnItemClickListener(onDialogItemClickListener listener) {

        this.itemClickListener = listener;
    }

    public interface onDialogItemClickListener {

        void onItemClick(String s);
    }

}
